<?php 
	include("includes/connect_db.php"); 

	$idFormat = $_POST['id'];
?>

<div class="kotakFilter">
	<div class="filterAll btnFilter">
		<span class="checkFilter">
			<?php
				$sql = "SELECT * FROM f_tb_mhs WHERE 
					telepon <> '' AND 
					telepon NOT LIKE '%/%' AND 
					telepon NOT LIKE '%-%' AND 
					telepon NOT LIKE '%,%' AND 
					telepon NOT LIKE '% %' AND 
					telepon NOT LIKE '%(%' AND 
					telepon NOT LIKE '%.%' AND 
					telepon NOT REGEXP '[abc]'
					ORDER BY nim";
				$query = mysql_query($sql);
				$jumlah = mysql_num_rows($query);

				$sqlCek = "SELECT * FROM tb_privilege WHERE id_operasi = '$idFormat' AND tipe = 'mahasiswa'";
				$queryCek = mysql_query($sqlCek);
				$jumlahCek = mysql_num_rows($queryCek);
				if ($jumlah == $jumlahCek) {
					echo "<input type='checkbox' value='mahasiswa' class='checkRealAll' checked='checked' style='display: none;'>";
		            echo "<i class='icon-check checkAll icon-white' style='opacity: 1.0'></i>";
				} else {
					echo "<input type='checkbox' value='mahasiswa' class='checkRealAll' style='display: none;'>";
            		echo "<i class='icon-check checkAll icon-white' style='opacity: 0.4'></i>";
				}
			?>
		</span>
		
		<span style="margin-left: 10px;">
			Mahasiswa
		</span>

        <span class="input-append" style="float: right; margin: 0px;">
            <input type="text" class="search-kontak">
            <span class="add-on">
                <i class="icon-search"></i>
            </span>
        </span>
        <div style="clear:both;"></div>

		<input type="hidden" value="0" class="cek">
	</div>
	<div class="isiFilter" style="display:none; clear: both;">
		<?php
			$sql = "SELECT * FROM f_tb_mhs WHERE 
					telepon <> '' AND 
					telepon NOT LIKE '%/%' AND 
					telepon NOT LIKE '%-%' AND 
					telepon NOT LIKE '%,%' AND 
					telepon NOT LIKE '% %' AND 
					telepon NOT LIKE '%(%' AND 
					telepon NOT LIKE '%.%' AND 
					telepon NOT REGEXP '[abc]'
					ORDER BY nim";

			$query = mysql_query($sql);
			while ($tampil = mysql_fetch_array($query)) {
				$sqlCek = "SELECT * FROM tb_privilege WHERE id_operasi = '$idFormat' AND tipe = 'mahasiswa' AND id_kontak = '$tampil[nim]'";
				$queryCek = mysql_query($sqlCek);
				$jumlah = mysql_num_rows($queryCek);

				if ($jumlah > 0) {
					echo "<div class='pilihFilter' style='background-color: #ddd'>";
						echo "<input type='checkbox' value='$tampil[nim]' class='checkReal' checked='checked' style='display: none;'>";
			            echo "<i class='icon-check check' style='opacity: 1.0'></i>";
				} else {
					echo "<div class='pilihFilter'>";
						echo "<input type='checkbox' value='$tampil[nim]' class='checkReal' style='display: none;'>";
			            echo "<i class='icon-check check' style='opacity: 0.4'></i>";
				}
						echo "<span style='margin-left: 10px;' class='searchNama' data-found='0'>";
							echo $tampil['nim']." - ".$tampil['nama']." (".$tampil['telepon'].")";
						echo "</span>";
					echo "</div>";
			}
		?>
	</div>
</div>

<div class="kotakFilter">
	<div class="filterAll btnFilter">
		<span class="checkFilter">
			<?php
				$sql = "SELECT * FROM f_tb_master_pegawai WHERE 
					telp <> '' AND 
					telp NOT LIKE '%/%' AND 
					telp NOT LIKE '%-%' AND 
					telp NOT LIKE '%,%' AND 
					telp NOT LIKE '% %' AND 
					telp NOT LIKE '%(%' AND 
					telp NOT LIKE '%.%' AND 
					telp NOT REGEXP '[abc]'
					ORDER BY nip_baru";
				$query = mysql_query($sql);
				$jumlah = mysql_num_rows($query);

				$sqlCek = "SELECT * FROM tb_privilege WHERE id_operasi = '$idFormat' AND tipe = 'dosen'";
				$queryCek = mysql_query($sqlCek);
				$jumlahCek = mysql_num_rows($queryCek);
				if ($jumlah == $jumlahCek) {
					echo "<input type='checkbox' value='dosen' class='checkRealAll' checked='checked' style='display: none;'>";
		            echo "<i class='icon-check checkAll icon-white' style='opacity: 1.0'></i>";
				} else {
					echo "<input type='checkbox' value='dosen' class='checkRealAll' style='display: none;'>";
		            echo "<i class='icon-check checkAll icon-white' style='opacity: 0.4'></i>";
				}
			?>
		</span>
		
		<span style="margin-left: 10px;">
			Dosen Pegawai
		</span>

		<span class="input-append" style="float: right; margin: 0px;">
            <input type="text" class="search-kontak">
            <span class="add-on">
                <i class="icon-search"></i>
            </span>
        </span>
        <div style="clear:both;"></div>
		<input type="hidden" value="0" class="cek">
	</div>
	<div class="isiFilter" style="display:none">
		<?php
			$sql = "SELECT * FROM f_tb_master_pegawai WHERE 
					telp <> '' AND 
					telp NOT LIKE '%/%' AND 
					telp NOT LIKE '%-%' AND 
					telp NOT LIKE '%,%' AND 
					telp NOT LIKE '% %' AND 
					telp NOT LIKE '%(%' AND 
					telp NOT LIKE '%.%' AND 
					telp NOT REGEXP '[abc]'
					ORDER BY nip_baru";

			$query = mysql_query($sql);
			while ($tampil = mysql_fetch_array($query)) {
				$sqlCek = "SELECT * FROM tb_privilege WHERE id_operasi = '$idFormat' AND tipe = 'dosen' AND id_kontak = '$tampil[nip_baru]'";
				$queryCek = mysql_query($sqlCek);
				$jumlah = mysql_num_rows($queryCek);

				if ($jumlah > 0) {
					echo "<div class='pilihFilter' style='background-color: #ddd'>";
						echo "<input type='checkbox' value='$tampil[nip_baru]' class='checkReal' checked='checked' style='display: none;'>";
			            echo "<i class='icon-check check' style='opacity: 1.0'></i>";
				} else {
					echo "<div class='pilihFilter'>";
						echo "<input type='checkbox' value='$tampil[nip_baru]' class='checkReal' style='display: none;'>";
			            echo "<i class='icon-check check' style='opacity: 0.4'></i>";
				}
					echo "<span style='margin-left: 10px;' class='searchNama' data-found='0'>";
						echo $tampil[nip_baru]." - ".$tampil[nama_lengkap]." (".$tampil[telp].")";	
					echo "</span>";
				echo "</div>";
			}
		?>
	</div>
</div>

<div class="kotakFilter">
	<div class="filterAll btnFilter">
		<span class="checkFilter">
			<?php
				$sql = "SELECT * FROM tb_kontak";
				$query = mysql_query($sql);
				$jumlah = mysql_num_rows($query);

				$sqlCek = "SELECT * FROM tb_privilege WHERE id_operasi = '$idFormat' AND tipe = 'kontak'";
				$queryCek = mysql_query($sqlCek);
				$jumlahCek = mysql_num_rows($queryCek);
				if ($jumlah == $jumlahCek) {
					echo "<input type='checkbox' value='kontak' class='checkRealAll' checked='checked' style='display: none;'>";
		            echo "<i class='icon-check checkAll icon-white' style='opacity: 1.0'></i>";
				} else {
					echo "<input type='checkbox' value='kontak' class='checkRealAll' style='display: none;'>";
		            echo "<i class='icon-check checkAll icon-white' style='opacity: 0.4'></i>";
				}
			?>
		</span>

		<span style="margin-left: 10px;">
			Kontak
		</span>

		<span class="input-append" style="float: right; margin: 0px;">
            <input class="search-kontak" type="text">
            <span class="add-on">
                <i class="icon-search"></i>
            </span>
        </span>
        <div style="clear:both;"></div>
		<input type="hidden" value="0" class="cek">
	</div>
	<div class="isiFilter" style="display:none">
		<?php
			$sql = "SELECT * FROM tb_kontak";
			$query = mysql_query($sql);
			while ($tampil = mysql_fetch_array($query)) {
				$sql_rincian = "SELECT * FROM tb_kontak_rincian WHERE id_kontak = '$tampil[id_kontak]' AND is_primary = '1'";
				$query_rincian = mysql_query($sql_rincian);
				$rincian = mysql_fetch_array($query_rincian);
				$sqlCek = "SELECT * FROM tb_privilege WHERE id_operasi = '$idFormat' AND tipe = 'kontak' AND id_kontak = '$tampil[id_kontak]'";
				$queryCek = mysql_query($sqlCek);
				$jumlah = mysql_num_rows($queryCek);

				if ($jumlah > 0) {
					echo "<div class='pilihFilter' style='background-color: #ddd'>";
						echo "<input type='checkbox' value='$tampil[id_kontak]' class='checkReal' checked='checked' style='display: none;'>";
			            echo "<i class='icon-check check' style='opacity: 1.0'></i>";
				} else {
					echo "<div class='pilihFilter'>";
						echo "<input type='checkbox' value='$tampil[id_kontak]' class='checkReal' style='display: none;'>";
			            echo "<i class='icon-check check' style='opacity: 0.4'></i>";
				}
					echo "<span style='margin-left: 10px;' class='searchNama' data-found='0'>";
						echo $tampil[nama_kontak]." (".$rincian[no_hp].")";	
					echo "</span>";
				echo "</div>";
			}
		?>
	</div>
</div>